<template>
  <DataList :cate="cate" :single="true" :name="name" :cols="cols"/>
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import {addZsfs,deleteZsfs,updateZsfs,getZsfs} from "@/api/招生方式.js";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A1-4 招生方式",
        name:'1.4 招生方式',
      cols: [
        { label: "全日制高职招生数", prop: "DNQRZGZZSJHS" },

        {
          label: "基于高考招生方式",
          data: [
            {
              label: "基于高考直接招生",
              data: [
                { label: "招生数", prop: "ZSS_ZJZS_ZSS" },
                { label: "比例(%)", prop: "ZSS_ZJZS_BL" }
              ]
            },
            {
              label: "基于高考的“知识+技能”招生",
              data: [
                { label: "招生数", prop: "ZSS_JYGK_ZSS" },
                { label: "比例(%)", prop: "ZSS_JYGK_BL" }
              ]
            }
          ]
        },

        {
          label: "其他招生方式",
          data: [
            {
              label: "对口招生",
              data: [
                { label: "招生数", prop: "ZSS_DKZS_ZSS" },
                { label: "比例(%)", prop: "ZSS_DKZS_BL" }
              ]
            },
            {
              label: "单独考试招生",
              data: [
                { label: "招生数", prop: "ZSS_DDKSZS_ZSS" },
                { label: "比例(%)", prop: "ZSS_DDKSZS_BL" }
              ]
            },
            {
              label: "综合评价招生",
              data: [
                { label: "招生数", prop: "ZSS_ZHPJZS_ZSS" },
                { label: "比例(%)", prop: "ZSS_ZHPJZS_BL" }
              ]
            },
            {
              label: "中高职贯通的招生",
              data: [
                { label: "招生数", prop: "ZSS_ZGZGTZS_ZSS" },
                { label: "比例(%)", prop: "ZSS_ZGZGTZS_BL" }
              ]
            },
            {
              label: "技能拔尖人才免试招生",
              data: [
                { label: "招生数", prop: "ZSS_JNBJRC_ZSS" },
                { label: "比例(%)", prop: "ZSS_JNBJRC_BL" }
              ]
            },
            {
              label: "补充方式",
              data: [
                { label: "招生数", prop: "ZSS_QT_ZSS" },
                { label: "比例(%)", prop: "ZSS_QT_BL" }
              ]
            }
          ]
        }
      ]
    };
  },
  methods: {
    
    async fetchData() {
      var user = getUser();
      var datas = await getZsfs(user.XXID,user.CJPC);
      return datas;
    },
    async  onChange(model, field, value) {
      
            
         model.DNQRZGZZSJHS = Number(model.ZSS_ZJZS_ZSS)+Number(model.ZSS_JYGK_ZSS)+Number(model.ZSS_DKZS_ZSS)+Number(model.ZSS_DDKSZS_ZSS)+Number(model.ZSS_ZHPJZS_ZSS)+Number(model.ZSS_ZGZGTZS_ZSS)+Number(model.ZSS_JNBJRC_ZSS)+Number(model.ZSS_QT_ZSS);
         model.ZSS_ZJZS_BL = ((Number(model.ZSS_ZJZS_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_JYGK_BL = ((Number(model.ZSS_JYGK_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_DKZS_BL = ((Number(model.ZSS_DKZS_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_DDKSZS_BL = ((Number(model.ZSS_DDKSZS_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_ZHPJZS_BL = ((Number(model.ZSS_ZHPJZS_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_ZGZGTZS_BL = ((Number(model.ZSS_ZGZGTZS_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_JNBJRC_BL = ((Number(model.ZSS_JNBJRC_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
         model.ZSS_QT_BL = ((Number(model.ZSS_QT_ZSS)/Number(model.DNQRZGZZSJHS))*100).toFixed(2)+'';
       
      //
    },
    onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model));
      return new Promise(async (resolve, reject) => {
      

        console.log(JSON.stringify(temp));
        var model = await addZsfs(temp);
        resolve(model);
      });
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model));
      return new Promise(async (resolve, reject) => {
       
        console.log(JSON.stringify(temp));
        var model = await updateZsfs(temp);
        resolve(model);
      });
      //
    },
    ondelete(model) {
      var temp = JSON.parse(JSON.stringify(model));
      return new Promise(async (resolve, reject) => {
        ;
        await deleteZsfs(temp);
        resolve();
      });
    }
  }
};
</script>
<style>
</style>